#include "FightResultDialog.h"
#include "Global.h"

FightResultDialog::FightResultDialog(void)
	:pItemIcon(NULL),pResultTitle(NULL),pItmeName(NULL)
{

}


FightResultDialog::~FightResultDialog(void)
{
}

bool FightResultDialog::init()
{
	bool bRet = false;
	do 
	{
		CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("fight_result_title.plist");
		pBg = CCSprite::create("battle_result_bg.png");
		pBg->setPosition(cult(pBg, 0, 250));
		pBg->setScaleY(1.8);
		this->addChild(pBg);

		pGold = CCLabelTTF::create("+500", "Arial", 15);
		pGold->setPosition(cult(pGold, 62, 280));
		pGold->setColor(ccc3(0, 255, 0));
		addChild(pGold);

		pExp = CCLabelTTF::create("+20", "Arial", 15);
		pExp->setPosition(cult(pExp, 62, 306));
		pExp->setColor(ccc3(0, 255, 0));
		addChild(pExp);

		pGoldTitle = CCLabelTTF::create("金币", "Arial", 15);
		pGoldTitle->setPosition(cult(pGoldTitle, 20, 280));
		addChild(pGoldTitle);

		pExpTitle = CCLabelTTF::create("经验", "Arial", 15);
		pExpTitle->setPosition(cult(pExpTitle, 20, 306));
		addChild(pExpTitle);

		/*m_pMenu = CCMenu::menuWithItems(okMenuItem, cancelMenuItem, NULL);
		m_pMenu->setPosition(CCPointZero);
		this->addChild(m_pMenu);*/

		bRet  = true;
	} while (0);

	return bRet;
}

void FightResultDialog::setItemIcon( int itemID )
{
	if(pItemIcon == NULL)
	{
		pItemIcon = CCSprite::create("item_02.png");
		pItemIcon->setPosition(cult(pItemIcon, 66, 166));
		pItemIcon->setScale(0.4);
		addChild(pItemIcon);
	}
	if (pItmeName == NULL)
	{
		pItmeName = CCLabelTTF::create("经验", "Arial", 15);
		pItmeName->setPosition(cult(pItmeName, 246, 326));
		addChild(pItmeName);
	}
	pItmeName->setString("神秘戒指");
	
}

void FightResultDialog::setResultTitle( bool succeed )
{
	if(pResultTitle == NULL)
	{
		pResultTitle = new CCSprite();
		pResultTitle->setPosition(cult(pResultTitle, 156, 106));
		addChild(pResultTitle);
	}
	CCSpriteFrame* frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(succeed?"fight_result_succeed.png":"fight_result_failed.png");
	pResultTitle->initWithSpriteFrame(frame);
}

void FightResultDialog::touchScreen()
{

}

void FightResultDialog::setGold( int gold )
{
	pGold->setString(ConvertUtil::intToChar(gold));
}

void FightResultDialog::setExp( int exp )
{
	pExp->setString(ConvertUtil::intToChar(exp));
}

